<?php

namespace App\Logic;


use App\server\CaseES;

class HouseReCometLogic
{

    public static function EsMultipleSearch($query, $field)
    {
        $es = new CaseES();
        //做高亮检索,多条件搜索
        $params = [
            'index' => $es->index,
            'body' => [
                'query' => [
                    'bool' => [
                        'must' => $query
                    ]
                ],
                //高亮
                'highlight' => [
                    'pre_tags' => [
                        "<span style='color: red'>",
                    ],
                    'post_tags' => ["</span>"],
                    'fields' => [
                        $field => new \stdClass()
                    ]
                ],
            ],
        ];
        $results = $es->client->search($params);
        $data = $results['hits']['hits'];
        return $data;
    }

}
